import { DoubleSide, Group, Points, Line, Material, Mesh, MeshLambertMaterial, Shape, ShapeGeometry, Vector2 } from "three";
import * as THREE from "three";
import { PCDLoader } from "three/examples/jsm/loaders/PCDLoader";
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";

const group = new Group();

let loader = new GLTFLoader();
loader.load("/data/上海外滩.glb", (gltf: any) => {
    console.log(gltf);
    let Floor = gltf.scene.getObjectByName("地面");
    Floor.material = new MeshLambertMaterial({
        color: "#444433"
    });

    let River = gltf.scene.getObjectByName("河面");
    River.material = new MeshLambertMaterial({
        color: "#336633"
    });

    //traverse递归遍历楼房下的所有模型
    gltf.scene.getObjectByName("楼房").traverse((item: any) => {
        item.material = new MeshLambertMaterial({
            // color: item.material.color, //读取原来材质的颜色
            color: 0xffffff,
        })
    })

    // 单独设置东方明珠材质
    var dongfang = gltf.scene.getObjectByName('东方明珠');
    dongfang.material = new MeshLambertMaterial({
        color: 0x996633,
    });

    group.add(gltf.scene);
});

// let pcdLoader = new PCDLoader();
// pcdLoader.load("./data/test.pcd", (pcd: any) => {
//     console.log(pcd);
//     pcd.scale.set(1, 1, 1);
//     group.add(pcd);
// });

export default group;